﻿using University.Workshop.DataAccess;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using University.Workshop.Model;
using University.Workshop.Business;
using System.Data;
using System.Collections.ObjectModel;

namespace University.Workshop.Tests
{
    
    
    /// <summary>
    ///This is a test class for AuctionDataAccessTest and is intended
    ///to contain all AuctionDataAccessTest Unit Tests
    ///</summary>
    [TestClass()]
    public class AuctionDataAccessTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for GetAuctionByproductId
        ///</summary>
        [TestMethod()]
        public void GetAuctionByproductIdTest()
        {
            Random rand = new Random();
            string email = "sara" + rand.Next(200) + "@yahoo.com";
            UserRegistrationManager.RegisterUser("Juan", "Perez", 'M', DateTime.Now, email, "saramontano1", "saramontano1", "Cochabamba", "Cochabamba", "79718989", "4483251");
            Product p = ProductRegistrationManager.RegisterNewProduct("Some valid product name", "1500", "Long description dfsdhkjf sfkjsd sdkfjdsl sdlkfjsdk fsdfjsdklf dsfkjsdklfk askljdakl fkdsjkslkaljasdkl", "Electronics", false, "Bolivianos", UserDataAccess.GetUserByEmail(email).Id,"1");
            Auction a = AuctionRegistrationManager.RegisterAuction(email, "100", "Bolivianos", p.ProductId.ToString(), DateTime.Now.AddDays(1), 10, 10);
            long auctionedProductId = a.Id; // TODO: Initialize to an appropriate value
            Auction expected = null; // TODO: Initialize to an appropriate value
            Auction actual;
            actual = AuctionDataAccess.GetAuctionByproductId(p.ProductId);
            Assert.AreNotEqual(expected, actual);
        }


        /// <summary>
        ///A test for GetAllAuctions
        ///</summary>
        [TestMethod()]
        public void GetAllAuctionsTest()
        {
            Collection<ProductAuction> actual;
            actual = AuctionDataAccess.AllAuctions();
            Assert.AreNotEqual(null, actual);
        }
    }
}
